import { adminArticles, admincreateData } from "@/type/article";
import request from "@/utils/request";

//查询文章列表
export const admingetArticles = (data: adminArticles) => {
  return request({
    url: "/admin/articles",
    method: "get",
    params: data,
  });
};

//查询文章详情
export const admingetArticleDetail = (id: string) => {
  return request({
    url: `/admin/articles/${id}`,
    method: "get",
  });
};

//创建文章
export const admincreateArticle = (data: admincreateData) => {
  return request({
    url: "/admin/articles",
    method: "post",
    data,
  });
};

//删除文章
export const admindeleteArticle = (id: string) => {
  return request({
    url: "/admin/articles/" + id,
    method: "delete",
  });
};

//更新文章
export const adminupdateArticle = (id: number, data: admincreateData) => {
  return request({
    url: `/admin/articles/${id}`,
    data,
    method: "put",
  });
};
